package pkg

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"mime/multipart"
	"time"
)

func Upload(file *multipart.FileHeader, c *gin.Context) (string, error) {
	fileName := fmt.Sprintf("upload/%s/%s", time.Now().Format("20060102"), file.Filename)
	err := c.SaveUploadedFile(file, "./"+fileName)
	if err != nil {
		return "", err
	}
	return fileName, err
}
